<template>
  <view>
    <free-nav-bar title="扫一扫" showBack :showCloseRigh="true"></free-nav-bar>
  </view>
</template>

<script>
import freeNavBar from "@/components/free-ui/free-nav-bar.vue";
export default {
  components: {
    freeNavBar,
  },
  data() {
    return {
      result: "",
    };
  },

  onLoad() {
    let reg = /^[0-9]+$/;
    // 在需要调用扫一扫功能的页面中
    uni.scanCode({
      success: (res) => {
        if (!res.result || !reg.test(res.result)) {
          uni.showToast({
            title: "请扫描正确的二维码",
            icon: "error",
          });
		  return;
        }
        uni.navigateTo({
        url: "/pages/tabbar/index/queryDetails",
      });
      },
      fail: (err) => {
        console.error("扫码失败", err);
        // 处理扫码失败情况
      },
    });
  },
  methods: {
  
  },
};
</script>

<style>
</style>